<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <form action="">
        <p>用户:<input type="text" id="username"></p>
        <p>密码:<input type="text" id="password"></p>
        <button id="btn">登录</button>
    </form>
    <script>
        btn.onclick = function () {
           var username=document.querySelector("#username").value
           var password=document.querySelector("#password").value
           var xhr=new XMLHttpRequest()
           xhr.open("GET","./06_project.php?username="+username+"&password="+password);
           xhr.send()
           xhr.onreadystatechange=function(){
               if(xhr.readyState===4&&/^2\d{2}/.test(xhr.status)){
                   if(xhr.responseText==="登录成功"){
                       alert('恭喜你登录成功')
                   }else{
                       alert("登录失败")
                   }
               }
           }
        }
    </script>
</body>

</html>